package com.cold.demo.redissession;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import java.util.List;

@SpringBootApplication
@Controller
public class DemoRedisSessionApplication implements ApplicationContextAware {

    ApplicationContext applicationContext;

//    @Value("${hiv}")
    private String hiv;


    public static void main(String[] args) {

        ConfigurableApplicationContext run = SpringApplication.run(DemoRedisSessionApplication.class, args);
        System.out.println("啓動完成");
    }


    @RequestMapping("/data")
    @ResponseBody
    public Object data(HttpServletRequest request) {
        HttpSession session = request.getSession();
        session.setAttribute("currentTime", System.currentTimeMillis());
        System.out.println();
        return System.currentTimeMillis() + "";
    }

    @Override
    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
        this.applicationContext = applicationContext;
    }


}
